.class public Lcom/alipay/android/app/util/PayHelper;
.super Ljava/lang/Object;


# instance fields
.field private mAlixPay:Lcom/alipay/android/app/IAlixPay;

.field private mCallback:Lcom/alipay/android/app/IRemoteServiceCallback;

.field private mContext:Landroid/app/Activity;

.field private mIsPaying:Z

.field private mLock:Ljava/lang/Object;

.field private mServiceConnection:Landroid/content/ServiceConnection;


# direct methods
.method public constructor <init>(Landroid/app/Activity;)V
    .locals 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/alipay/android/app/util/PayHelper;->mIsPaying:Z

    new-instance v0, Lcom/alipay/android/app/util/PayHelper$1;

    invoke-direct {v0, p0}, Lcom/alipay/android/app/util/PayHelper$1;-><init>(Lcom/alipay/android/app/util/PayHelper;)V

    iput-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mServiceConnection:Landroid/content/ServiceConnection;

    new-instance v0, Lcom/alipay/android/app/util/PayHelper$2;

    invoke-direct {v0, p0}, Lcom/alipay/android/app/util/PayHelper$2;-><init>(Lcom/alipay/android/app/util/PayHelper;)V

    iput-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mCallback:Lcom/alipay/android/app/IRemoteServiceCallback;

    iput-object p1, p0, Lcom/alipay/android/app/util/PayHelper;->mContext:Landroid/app/Activity;

    new-instance v0, Ljava/lang/Object;

    invoke-direct {v0}, Ljava/lang/Object;-><init>()V

    iput-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mLock:Ljava/lang/Object;

    return-void
.end method

.method static synthetic access$0(Lcom/alipay/android/app/util/PayHelper;Lcom/alipay/android/app/IAlixPay;)V
    .locals 0

    iput-object p1, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    return-void
.end method

.method static synthetic access$1(Lcom/alipay/android/app/util/PayHelper;)Ljava/lang/Object;
    .locals 1

    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mLock:Ljava/lang/Object;

    return-object v0
.end method

.method static synthetic access$2(Lcom/alipay/android/app/util/PayHelper;)Landroid/app/Activity;
    .locals 1

    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mContext:Landroid/app/Activity;

    return-object v0
.end method

.method private pay(Ljava/lang/String;Landroid/content/Intent;)Ljava/lang/String;
    .locals 5

    const/4 v3, 0x1

    const/4 v4, 0x0

    const/4 v2, 0x0

    iget-boolean v0, p0, Lcom/alipay/android/app/util/PayHelper;->mIsPaying:Z

    if-eqz v0, :cond_0

    const-string v0, ""

    :goto_0
    return-object v0

    :cond_0
    iput-boolean v3, p0, Lcom/alipay/android/app/util/PayHelper;->mIsPaying:Z

    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    if-nez v0, :cond_1

    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mContext:Landroid/app/Activity;

    invoke-virtual {v0}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    iget-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mServiceConnection:Landroid/content/ServiceConnection;

    invoke-virtual {v0, p2, v1, v3}, Landroid/content/Context;->bindService(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z

    :cond_1
    :try_start_0
    iget-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mLock:Ljava/lang/Object;

    monitor-enter v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    :try_start_1
    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    if-nez v0, :cond_2

    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mLock:Ljava/lang/Object;

    invoke-virtual {v0}, Ljava/lang/Object;->wait()V

    :cond_2
    monitor-exit v1
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :try_start_2
    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    iget-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mCallback:Lcom/alipay/android/app/IRemoteServiceCallback;

    invoke-interface {v0, v1}, Lcom/alipay/android/app/IAlixPay;->registerCallback(Lcom/alipay/android/app/IRemoteServiceCallback;)V

    iget-object v0, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    invoke-interface {v0, p1}, Lcom/alipay/android/app/IAlixPay;->Pay(Ljava/lang/String;)Ljava/lang/String;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    move-result-object v0

    :try_start_3
    iget-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    iget-object v3, p0, Lcom/alipay/android/app/util/PayHelper;->mCallback:Lcom/alipay/android/app/IRemoteServiceCallback;

    invoke-interface {v1, v3}, Lcom/alipay/android/app/IAlixPay;->unregisterCallback(Lcom/alipay/android/app/IRemoteServiceCallback;)V

    const/4 v1, 0x0

    iput-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_4

    :try_start_4
    iget-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mContext:Landroid/app/Activity;

    iget-object v3, p0, Lcom/alipay/android/app/util/PayHelper;->mServiceConnection:Landroid/content/ServiceConnection;

    invoke-virtual {v1, v3}, Landroid/app/Activity;->unbindService(Landroid/content/ServiceConnection;)V
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_3

    :goto_1
    iput-boolean v4, p0, Lcom/alipay/android/app/util/PayHelper;->mIsPaying:Z

    goto :goto_0

    :catchall_0
    move-exception v0

    :try_start_5
    monitor-exit v1
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    :try_start_6
    throw v0
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_6 .. :try_end_6} :catch_0

    :catch_0
    move-exception v0

    move-object v1, v0

    move-object v0, v2

    :goto_2
    :try_start_7
    invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_1

    :try_start_8
    iget-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mContext:Landroid/app/Activity;

    iget-object v3, p0, Lcom/alipay/android/app/util/PayHelper;->mServiceConnection:Landroid/content/ServiceConnection;

    invoke-virtual {v1, v3}, Landroid/app/Activity;->unbindService(Landroid/content/ServiceConnection;)V
    :try_end_8
    .catch Ljava/lang/Exception; {:try_start_8 .. :try_end_8} :catch_1

    :goto_3
    iput-boolean v4, p0, Lcom/alipay/android/app/util/PayHelper;->mIsPaying:Z

    goto :goto_0

    :catch_1
    move-exception v1

    iput-object v2, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    goto :goto_3

    :catchall_1
    move-exception v0

    :try_start_9
    iget-object v1, p0, Lcom/alipay/android/app/util/PayHelper;->mContext:Landroid/app/Activity;

    iget-object v3, p0, Lcom/alipay/android/app/util/PayHelper;->mServiceConnection:Landroid/content/ServiceConnection;

    invoke-virtual {v1, v3}, Landroid/app/Activity;->unbindService(Landroid/content/ServiceConnection;)V
    :try_end_9
    .catch Ljava/lang/Exception; {:try_start_9 .. :try_end_9} :catch_2

    :goto_4
    iput-boolean v4, p0, Lcom/alipay/android/app/util/PayHelper;->mIsPaying:Z

    throw v0

    :catch_2
    move-exception v1

    iput-object v2, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    goto :goto_4

    :catch_3
    move-exception v1

    iput-object v2, p0, Lcom/alipay/android/app/util/PayHelper;->mAlixPay:Lcom/alipay/android/app/IAlixPay;

    goto :goto_1

    :catch_4
    move-exception v1

    goto :goto_2
.end method


# virtual methods
.method public pay4Client(Ljava/lang/String;)Ljava/lang/String;
    .locals 2

    new-instance v0, Landroid/content/Intent;

    const-string v1, "com.eg.android.AlipayGphone.IAlixPay"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    invoke-direct {p0, p1, v0}, Lcom/alipay/android/app/util/PayHelper;->pay(Ljava/lang/String;Landroid/content/Intent;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public pay4Msp(Ljava/lang/String;)Ljava/lang/String;
    .locals 2

    new-instance v0, Landroid/content/Intent;

    const-class v1, Lcom/alipay/android/app/IAlixPay;

    invoke-virtual {v1}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    invoke-direct {p0, p1, v0}, Lcom/alipay/android/app/util/PayHelper;->pay(Ljava/lang/String;Landroid/content/Intent;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method
